﻿<phone:PhoneApplicationPage 
    x:Class="Flickr.Sample.PhotoView"
    xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
    xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
    xmlns:phone="clr-namespace:Microsoft.Phone.Controls;assembly=Microsoft.Phone"
    xmlns:shell="clr-namespace:Microsoft.Phone.Shell;assembly=Microsoft.Phone"
    xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
    xmlns:agfx="clr-namespace:AgFx;assembly=AgFx"
    xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
    xmlns:controls="clr-namespace:Microsoft.Phone.Controls;assembly=Microsoft.Phone.Controls" 
    xmlns:controlsPrimitives="clr-namespace:Microsoft.Phone.Controls.Primitives;assembly=Microsoft.Phone.Controls" 
    xmlns:toolkit="clr-namespace:Microsoft.Phone.Controls;assembly=Microsoft.Phone.Controls.Toolkit" 
    xmlns:agfxctls="clr-namespace:AgFx.Controls;assembly=AgFx.Controls"
    FontFamily="{StaticResource PhoneFontFamilyNormal}"
    FontSize="{StaticResource PhoneFontSizeNormal}"
    Foreground="{StaticResource PhoneForegroundBrush}"
    SupportedOrientations="PortraitOrLandscape" Orientation="Portrait"
    mc:Ignorable="d" d:DesignHeight="768" d:DesignWidth="480"
    shell:SystemTray.IsVisible="True">


    <phone:PhoneApplicationPage.Resources>
        <DataTemplate x:Key="PivotHeaderTemplate">
            <TextBlock Text="{Binding}" Style="{StaticResource PhoneTextTitle2Style}" />
        </DataTemplate>
        <Style x:Key="PivotStyle1" TargetType="controls:Pivot">
            <Setter Property="Margin" Value="0"/>
            <Setter Property="Padding" Value="0"/>
            <Setter Property="Foreground" Value="{StaticResource PhoneForegroundBrush}"/>
            <Setter Property="Background" Value="Transparent"/>
            <Setter Property="ItemsPanel">
                <Setter.Value>
                    <ItemsPanelTemplate>
                        <Grid/>
                    </ItemsPanelTemplate>
                </Setter.Value>
            </Setter>
            <Setter Property="Template">
                <Setter.Value>
                    <ControlTemplate TargetType="controls:Pivot">
                        <Grid HorizontalAlignment="{TemplateBinding HorizontalAlignment}" VerticalAlignment="{TemplateBinding VerticalAlignment}">
                            <Grid.RowDefinitions>
                                <RowDefinition Height="Auto"/>
                                <RowDefinition Height="Auto"/>
                                <RowDefinition Height="*"/>
                            </Grid.RowDefinitions>
                            <Grid Background="{TemplateBinding Background}" CacheMode="BitmapCache" Grid.RowSpan="3"/>
                            <controlsPrimitives:PivotHeadersControl x:Name="HeadersListElement" Grid.Row="1"/>
                            <ItemsPresenter x:Name="PivotItemPresenter" Margin="{TemplateBinding Padding}" Grid.Row="2"/>
                        </Grid>
                    </ControlTemplate>
                </Setter.Value>
            </Setter>
        </Style>
    </phone:PhoneApplicationPage.Resources>

    <Grid x:Name="LayoutRoot" Background="{StaticResource PhoneBackgroundBrush}" >
        <Grid.RowDefinitions>
            <RowDefinition Height="Auto"/>
            <RowDefinition Height="*"/>
        </Grid.RowDefinitions>

        <!--This is the name of the application and page title-->
        <Grid Grid.Row="0" x:Name="TitleGrid">

            <TextBlock x:Name="photoName" Text="{Binding Title}" Style="{StaticResource PhoneTextLargeStyle}" Margin="2"/>
        </Grid>

        <Grid Grid.Row="1" x:Name="ContentGrid">
            <Grid.RowDefinitions>
                <RowDefinition Height="*" />
                <RowDefinition Height="Auto" />
            </Grid.RowDefinitions>

            <Grid Grid.Row="0">
                <Grid.ColumnDefinitions>
                    <ColumnDefinition Width="25*" />
                    <ColumnDefinition Width="50*" />
                    <ColumnDefinition Width="25*" />
                </Grid.ColumnDefinitions>
                <Rectangle Fill="#05FFFFFF" MinHeight="50" Grid.ColumnSpan="2" />
                <TextBlock Text="Loading..." HorizontalAlignment="Center" VerticalAlignment="Center" Grid.ColumnSpan="3" />
                <Image x:Name="img" Source="{Binding PhotoUrls.DisplayUrl}" HorizontalAlignment="Center" VerticalAlignment="Center"  Stretch="Uniform" Grid.ColumnSpan="3"  ManipulationCompleted="Image_Tap" />

                <Rectangle Fill="Transparent" ManipulationCompleted="PreviousImage_Tap"/>
                <Rectangle Fill="Transparent" Grid.Column="2" ManipulationCompleted="NextImage_Tap"/>

            </Grid>

            <controls:Pivot x:Name="detailsPivot" MinHeight="100" MaxHeight="250" Grid.Row="1" Margin="5" Title="" Background="#18FFFFFF" HeaderTemplate="{StaticResource PivotHeaderTemplate}" Style="{StaticResource PivotStyle1}">
                <controls:PivotItem x:Name="info" Header="info">
                    <Grid  Margin="2">
                        <Grid.RowDefinitions>
                            <RowDefinition Height="*"/>
                            <RowDefinition Height="Auto"/>

                        </Grid.RowDefinitions>
                        <ScrollViewer x:Name="svDescription"  VerticalScrollBarVisibility="Auto" HorizontalScrollBarVisibility="Disabled" Margin="0">
                            <StackPanel>
                                <TextBlock TextWrapping="Wrap" Text="{Binding Description}" Style="{StaticResource PhoneTextSubtleStyle}" Margin="2,0" />                                                                
                                <TextBlock Text="{Binding Converter={StaticResource stringFormatConverter}, Path=Posted, ConverterParameter=Posted: \{0:ddd\, MMM dd\, yyyy mm:hh:ss\}}" Style="{StaticResource PhoneTextSubtleStyle}" FontStyle="Italic" FontWeight="Bold" HorizontalAlignment="Left"/>
                                <TextBlock Text="{Binding Converter={StaticResource stringFormatConverter}, Path=Owner.UserName, ConverterParameter=By: \{0\}}" Style="{StaticResource PhoneTextSubtleStyle}" FontStyle="Italic" FontWeight="Bold" HorizontalAlignment="Left"/>
                            </StackPanel>                            
                        </ScrollViewer>


                    </Grid>

                </controls:PivotItem>
                <controls:PivotItem x:Name="tags" Header="tags" >
                    <Grid>
                        <TextBlock Text="No tags defined." Visibility="{Binding Path=Tags.Count, Converter={StaticResource visibilityConverter},ConverterParameter=!}" />
                        <ScrollViewer>
                            <ItemsControl ItemsSource="{Binding Tags}">
                                <ItemsControl.ItemsPanel>
                                    <ItemsPanelTemplate>
                                        <toolkit:WrapPanel/>
                                    </ItemsPanelTemplate>
                                </ItemsControl.ItemsPanel>
                                <ItemsControl.ItemTemplate>
                                    <DataTemplate>
                                        <agfxctls:HyperlinkButtonEx Content="{Binding RawTag}" NavigateUrlFormat="/SearchView.xaml?tag={0}" NavigateUrlParam="{Binding Tag}" Margin="0,0,0,0" HorizontalAlignment="Left" VerticalAlignment="Top"/>
                                    </DataTemplate>
                                </ItemsControl.ItemTemplate>
                            </ItemsControl>
                        </ScrollViewer>

                    </Grid>
                </controls:PivotItem>
                <!--<controls:PivotItem x:Name="comments" Header="comments" >
                    <Grid>
                        <TextBlock Text="No Comments"  Visibility="{Binding Comments.Count, ConverterParameter=!, Converter={StaticResource visibilityConverter}}"/>
                        <ScrollViewer  x:Name="svComments" HorizontalScrollBarVisibility="Disabled" Visibility="{Binding Comments.Count, Converter={StaticResource visibilityConverter}}">

                            <ItemsControl ItemsSource="{Binding Comments}" >

                                <ItemsControl.ItemTemplate>
                                    <DataTemplate>
                                        <Grid>
                                            <Grid.RowDefinitions>
                                                <RowDefinition Height="Auto"/>
                                                <RowDefinition Height="Auto"/>
                                            </Grid.RowDefinitions>

                                            <TextBlock  FontWeight="Bold" Style="{StaticResource PhoneTextNormalStyle}" Text="{Binding Author.UserName}"/>
                                            <TextBlock Style="{StaticResource PhoneTextSubtleStyle}" Text="{Binding Date}" HorizontalAlignment="Right" />


                                            <TextBlock  Style="{StaticResource PhoneTextNormalStyle}"  Text="{Binding Comment}" Grid.Row="1" HorizontalAlignment="Left" TextWrapping="Wrap" FontStyle="Italic" Margin="5,0"/>

                                        </Grid>
                                    </DataTemplate>
                                </ItemsControl.ItemTemplate>
                            </ItemsControl>
                        </ScrollViewer>

                    </Grid>



                </controls:PivotItem>-->
            </controls:Pivot>





        </Grid>
    </Grid>

    
  

</phone:PhoneApplicationPage>
